<include file="public@header"/>
<style type="text/css">
    .pic-list li {
        margin-bottom: 5px;
    }
</style>
</head>
<body>
<div class="wrap js-check-wrap">
    <div class="well form-inline margin-top-20""><a class="btn btn-default" href="{:url('Alsdk/DescribeUserDomains')}"><<返回域名列表</a>&nbsp;&nbsp;{$domain}</div>
    <ul class="nav nav-tabs">
        <li><a href="{:url('Alsdk/DescribeLiveStreamTranscodeInfo', array('domain'=>$domain))}">转码配置信息列表</a></li>
        <li class="active"><a href="{:url('Alsdk/AddLiveStreamTranscode', array('domain'=>$domain))}">添加转码配置</a></li>
        <li><a href="{:url('Alsdk/AddCustomLiveStreamTranscode', array('domain'=>$domain))}">添加自定义转码配置</a></li>
    </ul>
    <form action="{:url('Alsdk/AddLiveStreamTranscode')}" method="post" class="form-horizontal js-ajax-form margin-top-20">
        <div class="form-group">
            <label class="col-sm-2 control-label"><span class="form-required">*</span>直播流所属应用名称:</label>
            <div class="col-md-6 col-sm-10">
                <input class="form-control" type="text" name="App" required value="" placeholder="App"/>
                <p class="help-block">AppName 名称与推流地址中的 AppName 名称对应，模板才能生效</p>
            </div>
        </div>
        <input class="form-control" type="hidden" name="Domain" value="{$domain}"/>
        <div class="form-group">
            <label class="col-sm-2 control-label"><span class="form-required">*</span>标准模板:</label>
            <div class="col-md-6 col-sm-10">
                <input type="radio" value="lld" name="Template" />流畅（LD）
                <input type="radio" value="lsd" name="Template" />标清（SD）
                <input type="radio" value="lhd" name="Template" />高清（HD）
                <input type="radio" value="lud" name="Template" />超清（UD）
                <p class="help-block">标准模板与窄带高清模板二选一即可</p>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label"><span class="form-required">*</span>窄带高清模板:</label>
            <div class="col-md-6 col-sm-10">
                <input type="radio" value="ld" name="Template" />流畅（LD）
                <input type="radio" value="sd" name="Template" />标清（SD）
                <input type="radio" value="hd" name="Template" />高清（HD）
                <input type="radio" value="ud" name="Template" />超清（UD）
                <p class="help-block">标准模板与窄带高清模板二选一即可</p>
            </div>
        </div>
        <div class="col-sm-offset-2 col-sm-10">
            <button type="button" class="btn btn-primary" id="js-ajax-submit">{:lang("SAVE")}</button>
            <a class="btn btn-default" href="{:url('Alsdk/DescribeLiveStreamTranscodeInfo', array('domain'=>$domain))}">返回</a>
        </div>
    </form>
</div>
<script type="text/javascript" src="__STATIC__/js/admin.js"></script>
<script type="text/javascript">
    $('#js-ajax-submit').on('click', function () {
        var data = {
            App:$("input[name='App']").val(),
            Template:$('input[name="Template"]:checked').val(),
            Domain:$("input[name='Domain']").val(),
        }
        if ( data.App == '' || data.App == null ) {
            tishi('AppName不能为空')
            return false
        } else if ( data.Template == '' || data.Template == null ) {
            tishi('请选择模板')
            return false
        }
        $.ajax({
            url: "{:url('Alsdk/AddLiveStreamTranscode')}",
            dataType: 'json',
            data: data,
            type: "POST",
            success: function(data){
                if (data.code == '1') {
                    noty({
                        text: data.msg,
                        type: 'success',
                        layout: 'topCenter',
                        modal: true,
                        timeout: 800,
                        callback: {
                            afterClose: function () {
                                if (data.url) {
                                    //返回带跳转地址
                                    window.location.href = data.url;
                                } else {
                                    //刷新当前页
                                    reloadPage(window);
                                }
                            }
                        }
                    }).show();
                } else if (data.code == '0') {
                    art.dialog({
                        content: data.msg,
                        icon: 'warning',
                        ok: function () {
                            this.title(data.msg);
                            return true;
                        }
                    });
                }
            }
        });
    });

    // 信息提示
    function tishi(msg){
        art.dialog({
            id: 'warning',
            icon: 'warning',
            title: '提示',
            content: msg,
            cancelVal: '关闭',
            ok: function () {
              
            }
        });
    }
</script>
</body>
</html>
